import Vue from 'vue';

//directive 自定义指令     permission 指令的名字
Vue.directive('permission', {
    //el 你写指令的那个父元素    binding 你指令上写的值
    inserted: (el, binding, vnode) => {
        const value = binding.value;
        let permissions = localStorage.getItem('permissions');
        if (permissions){
            let auths = JSON.parse(permissions);
            if (auths.join(",").indexOf(value)==-1) {
                el.parentNode.removeChild(el);//删除元素
            }
        }
    }
});
